home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Extra 1997 #1 / Amiga Plus Extra 1997 #1.iso / programme / grafik / video easel / camrexx / isingiii.rexx < prev    next >
OS/2 REXX Batch file  |  1995-03-30  |  2KB  |  61 lines

  1. /* Cannonical Ising Model, by an idea of Toffoli, in CAMRexx by THOR */
  2.  
  3.  
  4. MakeAlgorithm:
  5.    if plane=2 then
  6.       PLANEALGORITHM neumann hvpc
  7.    else
  8.       PLANEALGORITHM margolus hvphases
  9. return
  10.  
  11. MakePlane:
  12.    /* Random generator in planes 0..1 */
  13.    /* Please note that the "Neumann-hvpc" algorithm has a different
  14.       naming convention... see the docs. */
  15.    if plane=0 then; do
  16.       if center=opp & cw=ccw & center~=cw then
  17.             SETPLANE cw
  18.       else  SETPLANE opp
  19.    end
  20.    if plane=1 then; do
  21.       if center=opp & cw=ccw & center~=cw then
  22.             SETPLANE center
  23.       else; do
  24.          if phase then  SETPLANE cw
  25.          else           SETPLANE ccw
  26.       end
  27.    end
  28.    /* Ising-model in plane 2 */
  29.    if plane=2 then; do
  30.       lattice=(horz=vert)
  31.       if phase=1 then   lattice=~lattice
  32.    /* handle only even or odd sublattice */
  33.       if lattice then; do
  34.          /* calculate bond energy of the spin */
  35.          bonds=north+south+east+west
  36.          if center then
  37.             bonds=4-bonds
  38.          /* simple random value */
  39.          p=alt
  40.          /* squared */
  41.          p2=alt & alt_
  42.          /* and now the new spin-value */
  43.          new=center
  44.          select
  45.             when bonds=0 then; do
  46.                if p2 then new=~new  /* flip */
  47.             end
  48.             when bonds=1 then; do
  49.                if p then new=~new   /* flip */
  50.             end
  51.             otherwise
  52.                new=~new
  53.          end
  54.          SETPLANE new
  55.       end; else; do;
  56.          SETPLANE center
  57.       end
  58.    end
  59. return
  60.  
  61.